import 'package:get/get.dart';
import 'package:honeypotflutter/net/public_http.dart';
import 'package:honeypotflutter/publicBussine/loginInfo/bussine_userInfoModel.dart';

class UserInfoLogic extends GetxController {
  /// 个人信息
  UserInfoModel userInfo = UserInfoModel();

  /// 认证状态
  bool authenticationStatus = false;

  @override
  void onInit() {
    // TODO: implement onInit
    super.onInit();
  }

  /*
  *  请求个人信息
  * */
  Future<UserInfoModel> requestUserInfo() async {
    try {
      var result = await MGHttp.get<Map<String, dynamic>>("api/services/app/Account/GetMyUserDetails");
      if (result != null) {
        var userModel = UserInfoModel.fromJson(result);
        userInfo = userModel;
        authenticationStatus = (userModel.realNameStatus == 1) && (userModel.accountState == 11);
        update();
      }
      return userInfo;
    } catch (error) {
      return Future.error(error);
    }
  }

  /*
  * 改变支付方式
  * */
  changePayType(int type) async {
    userInfo.userFirstChoicePayType = type;
    update();
  }
}
